
package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

/**
 *
 * @author Gautier
 */
public class MainFrame extends javax.swing.JFrame implements ActionListener{
                        
    private DefaultListModel l1;
    private DefaultListModel l2;
    private GroupList l_left;
    private ContactList l_right;
    private ContactDisplay cd;
    private ArrayList al;
    private Menu m;

    public MainFrame(ArrayList a){
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
        al=a;
        m = new Menu(al, this);
        this.setJMenuBar(m);
        initComponents();
        this.repaint();
    }

                         
    private void initComponents() {
        cd = new ContactDisplay(al);
        l_right= new ContactList(al, cd);
        l_left= new GroupList(l_right);
        
        

        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(l_left, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
                .addComponent(l_right, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
                .addComponent(cd, GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addComponent(l_left)
            .addComponent(l_right)
            .addComponent(cd, GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)
        );
        cd.setBorder(BorderFactory.createTitledBorder("Informations"));
        pack();
        this.setVisible(true);
    }                                    
    
    
    @Override
    public void actionPerformed(ActionEvent e) {
        
    }
}
